package top.soulblack.purchasesale.model;

import java.util.List;
import java.util.Map;

public class WechatTableColumn {
    private Integer id;

    private Integer pid;

    private String type;

    private String editType;

    private Integer len;

    private String describe;

    private String name;

    private Integer linkId;

    private Integer auth;

    private List<Map<String,Object>> data;

    private WechatTableClassify wechatTableClassify;

    private WechatTableColumn linkColumn;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getPid() {
        return pid;
    }

    public void setPid(Integer pid) {
        this.pid = pid;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type == null ? null : type.trim();
    }

    public String getEditType() {
        return editType;
    }

    public void setEditType(String editType) {
        this.editType = editType == null ? null : editType.trim();
    }

    public Integer getLen() {
        return len;
    }

    public void setLen(Integer len) {
        this.len = len;
    }

    public String getDescribe() {
        return describe;
    }

    public void setDescribe(String describe) {
        this.describe = describe == null ? null : describe.trim();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    public Integer getLinkId() {
        return linkId;
    }

    public void setLinkId(Integer linkId) {
        this.linkId = linkId;
    }

    public Integer getAuth() {
        return auth;
    }

    public void setAuth(Integer auth) {
        this.auth = auth;
    }

    public List<Map<String,Object>> getData(){ return data;}

    public void setData(List<Map<String, Object>> data) {
        this.data = data;
    }

    public WechatTableClassify getWechatTableClassify(){return wechatTableClassify;}

    public WechatTableColumn getLinkColumn(){return linkColumn;}

    public void  setLinkColumn(WechatTableColumn linkColumn){this.linkColumn = linkColumn;}

    public boolean hasLinkId(){
        if(this.linkId == null){
            return false;
        }
        return true;
    }

    public Object getLinkValue(Object value){
        String index = this.linkColumn.getWechatTableClassify().getIndex();
        for (Map<String,Object>intear:this.data){
            if(intear.containsKey(index))
                if (intear.get(index) == value){
                    return intear.get(this.linkColumn.getName());
                }
        }
        return null;
    }
}